<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // let a = [1, 2, 3, 4, 5];
    // let b = [3, 4, 5, 6, 8];
    //需求： let c = [1,2,5,6];  // ? 找非公共项

    // let c = [];
    let arr1 = [0, 1, 2, 3, 4, 5];
    let arr2 = [0, 4, 6, 1, 3, 9];
    let c = [];

    //第一种方法
    //  function getArrDifference(arr1, arr2) 
    //  { return arr1.concat(arr2).filter(function (v, i, arr) 
    //     { return arr.indexOf(v) === arr.lastIndexOf(v); }); } 
     
    //     console.log(getArrDifference(arr1, arr2))


    //第二种方法
    for(let i = 0;i < arr1.length;i++){
        if(!arr2.includes(arr1[i])){
            c.push(arr1[i]);
        }

        if(!arr1.includes(arr2[i])){
            c.push(arr2[i]);
        }

    }

    //第三种方法
    // for(let i = 0;i<arr1.length;i++){
    //     if(!arr2.includes(arr1[i])){
    //         c.push(arr1[i]);
    //     }
    // }

    // for(let i = 0;i<arr2.length;i++){
    //     if(!arr1.includes(arr2[i])){
    //         c.push(arr2[i]);
    //     }
    // }

    console.log(c);

</script>

</html>